<template>
  <basic-container>
    <avue-crud :option="option" :data="data" :page="page" ref="crud" @search-change="searchChange" @search-reset="searchReset"
      @current-change="currentChange" @size-change="sizeChange" @on-load="onLoad">
    </avue-crud>
  </basic-container>
</template>

<script>
  import request from '@/router/axios';
  import {
    getCodes
  } from "@/api/system/dict";

  export default {
    data() {
      return {
        query: {},
        page: {
          pageSize: 10,
          currentPage: 1,
          total: 0
        },
        option: {
          searchMenuSpan: 4,
          border: true,
          index: true,
          menu:false,
          addBtn:false,
          refreshBtn:false,
          excelBtn:true,
          column: [
			  {
			  	label: "所属仓库",
			  	prop: "storeCode",
			  	searchSpan: 6,
			  	search: true,
			  	filterable: true,
			  	searchFilterable: true,
			  	clearable: false,
			  	group: true,
			  	width: "250px",
			  	editDisabled: true,
			  	type: "select",
			  	dicData: []
			  },{
              label: "库位编号",
              prop: "localCode",
              searchPlaceholder: '库位&条码',
              search: true
            },
            {
              label: "条码",
              prop: "barCode"
            },
            {
              label: "数量",
              prop: "quantity",
			  width:150
            },
            {
              label: "操作时间",
              prop: "updatedOn",
			  width:160
            }
          ]
        },
        data: []
      };
    },
    created() {
			request({
				url: '2/api/WmsStorage/groups',
			}).then(res => {
				this.findObject(this.option.column, 'storeCode').dicData = res.data.data;
			});
    },
    methods: {
      searchReset() {
        this.query = {};
        this.page.currentPage = 1;
        this.onLoad(this.page);
      },
      searchChange(params, done) {
        this.page.currentPage = 1;
        this.query = params;
        this.onLoad(this.page);
        done();
      },
      currentChange(currentPage) {
        this.page.currentPage = currentPage;
      },
      sizeChange(pageSize) {
        this.page.pageSize = pageSize;
      },
      onLoad(page) {
        request({
          url: '2/api/WmsInventory/getpages',
          params: {
            key: this.query.localCode == undefined ? '' : this.query.localCode,
            type: this.query.storeCode == undefined ? '' : this.query.storeCode,
            page: page.currentPage,
            limit: page.pageSize
          }
        }).then(res => {
          const data = res.data
          this.data = data.data;
          this.page.total = data.remark;
        });
      }
    }
  };
</script>

<style>
</style>
